package com.kexio.pay.event;

import java.math.BigDecimal;
import java.time.LocalDateTime;

import org.springframework.context.ApplicationEvent;

/**
 * 支付成功事件
 * 
 * 当支付成功后，发布此事件通知业务模块执行后续逻辑
 * 
 * @author Kexio Team
 * @since 1.0.0
 */
public class PaymentSuccessEvent extends ApplicationEvent {
    
    private static final long serialVersionUID = 1L;
    
    /**
     * 订单号
     */
    private final String orderNo;
    
    /**
     * 业务类型 (1-单帖购买, 2-会员订阅, 3-打赏)
     */
    private final String businessType;
    
    /**
     * 业务ID
     */
    private final String businessId;
    
    /**
     * 用户ID
     */
    private final String userId;
    
    /**
     * 支付金额
     */
    private final BigDecimal amount;
    
    /**
     * 支付方式
     */
    private final String paymentMethod;
    
    /**
     * 第三方交易号
     */
    private final String thirdPartyTradeNo;
    
    /**
     * 支付时间
     */
    private final LocalDateTime paymentTime;
    
    public PaymentSuccessEvent(Object source, String orderNo, String businessType, 
                              String businessId, String userId, BigDecimal amount, 
                              String paymentMethod, String thirdPartyTradeNo) {
        super(source);
        this.orderNo = orderNo;
        this.businessType = businessType;
        this.businessId = businessId;
        this.userId = userId;
        this.amount = amount;
        this.paymentMethod = paymentMethod;
        this.thirdPartyTradeNo = thirdPartyTradeNo;
        this.paymentTime = LocalDateTime.now();
    }
    
    // Getters
    public String getOrderNo() { return orderNo; }
    public String getBusinessType() { return businessType; }
    public String getBusinessId() { return businessId; }
    public String getUserId() { return userId; }
    public BigDecimal getAmount() { return amount; }
    public String getPaymentMethod() { return paymentMethod; }
    public String getThirdPartyTradeNo() { return thirdPartyTradeNo; }
    public LocalDateTime getPaymentTime() { return paymentTime; }
    
    @Override
    public String toString() {
        return "PaymentSuccessEvent{" +
                "orderNo='" + orderNo + '\'' +
                ", businessType='" + businessType + '\'' +
                ", businessId='" + businessId + '\'' +
                ", userId='" + userId + '\'' +
                ", amount=" + amount +
                ", paymentMethod='" + paymentMethod + '\'' +
                ", thirdPartyTradeNo='" + thirdPartyTradeNo + '\'' +
                ", paymentTime=" + paymentTime +
                '}';
    }
}

